﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace PptToImg
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            string pptPath = "ppt.pptx";
            string imgPath = "img\\";
       var x=     Assembly.GetExecutingAssembly().Location;

            string p = Directory.GetCurrentDirectory();
            var app = new Microsoft.Office.Interop.PowerPoint.Application();
            var ppt = app.Presentations.Open(p+"\\"+pptPath, Microsoft.Office.Core.MsoTriState.msoFalse, Microsoft.Office.Core.MsoTriState.msoFalse, Microsoft.Office.Core.MsoTriState.msoFalse);
            var index = 0;
            var fileName = System.IO.Path.GetFileNameWithoutExtension(pptPath);

           // app.Active.View.Zoom = 100;
         

            foreach (Microsoft.Office.Interop.PowerPoint.Slide slid in ppt.Slides)
            {
             
                 
                ++index;
                //设置图片大小
                slid.Export(p+"\\"+imgPath + string.Format("page{0}.png", index.ToString()), "png", 1024*4, 768*4);
               
            }
            //释放资源
            ppt.Close();
            app.Quit();
          
        }
    }
}
